﻿<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>BootDo</title>
    <meta name="keywords" content="学生宿舍管理系统">
    <meta name="description" content="学生宿舍管理系统">
    <link th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/static/css/font-awesome.css?v=4.4.0}" rel="stylesheet">
    <link th:href="@{/static/css/animate.css}" rel="stylesheet">
    <link th:href="@{/static/css/style.css}" rel="stylesheet">
    <link th:href="@{/static/css/login.css}" rel="stylesheet">
    <!-- 全局js -->
    <script th:src="@{/static/js/jquery.min.js?v=2.1.4}"></script>
    <script th:src="@{/static/js/bootstrap.min.js?v=3.3.6}"></script>
    <!-- 自定义js -->
    <script th:src="@{/static/js/content.js?v=1.0.0}"></script>
    <!-- jQuery Validation plugin javascript-->
    <script th:src="@{/static/js/validate/jquery.validate.min.js}"></script>
    <script th:src="@{/static/js/validate/messages_zh.min.js}"></script>
    <script th:src="@{/static/js/layer/layer.min.js}"></script>
    <script th:src="@{/static/js/admin/util.js}"></script>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        //设置当前窗口为顶层窗口
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
    <script type="text/javascript" th:inline="javascript">
        var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
    </script>
</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1><strong>学生宿舍后台管理系统</strong></h1>
                </div>
                <div class="m-b"></div>
                <h3>
                    导航...
                </h3>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        学生信息管理
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 宿舍信息维护</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 宿舍常规统计</li>
                </ul>

            </div>
        </div>
        <div class="col-sm-5">
            <form id="signupForm">
                <h3 class="text-center"><strong>用户登录</strong></h3>
                <input type="text" name="username" class="form-control uname"
                       value="superEtouch"/>
                <input type="password" name="password"
                       class="form-control pword m-b" value="111111"/>
                <button class="btn btn-login btn-block">登录</button>
                <!--按钮模块-->
                <div class="outside-login">
                    <div class="outside-login-tit">
                        <span>友情链接</span>
                    </div>
                    <div class="outside-login-cot">
                        <a class="outside-login-btn wxoa actived oschina J-btnSwitchLoginType" target="_self"
                           th:href="@{/login}">
                            <em><i class="fa fa-home"></i></em>
                            <span>学院主页</span>
                        </a>
                    </div>
                </div>

            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">&copy; 2017 All Rights Reserved. BootDo
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        validateRule();
        //进行表单校验
//        $("#signupForm").validate();
    });
    $.validator.setDefaults({
        submitHandler: function () {
            login();
        }
    });

    //登录操作
    function login() {
        var load;
        $.ajax({
            type: "POST",
            url: basePath + "/login",
            data: $('#signupForm').serialize(),
            success: function (r) {
                layer.close(load);
                var data = JSON.parse(r);
                if (data.status == 1000) {
                    parent.location.href = basePath + '/main';
                } else {
                    layer.msg(data.desc, function () {

                    });
                }
            },
            beforeSend: function (x) {
                load = layer.load(2, {shade: [0.4, '#393D49']})
            },
        });
    }

    //校验表单数据
    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名",
                },
                password: {
                    required: icon + "请输入您的密码",
                }
            }
        })
    }
</script>
</body>


</html>
